home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / copytext.java < prev    next >
Encoding:
Java Source  |  2001-06-13  |  1.1 KB  |  60 lines

  1. import java.awt.*;
  2.  
  3. public class copytext extends java.applet.Applet
  4. {
  5.   TextField  tf1, tf2;
  6.    public void init()
  7.    {
  8.       setLayout(new BorderLayout());
  9.  
  10.       Panel p;
  11.  
  12.       p = new Panel();
  13.  
  14.       p.setLayout(new GridLayout(0, 2));
  15.  
  16.       p.add(new Label("Type Text Here:"));
  17.       tf1 = new TextField("");
  18.       p.add(tf1);
  19.  
  20.       p.add(new Label("Click Button to Copy:"));
  21.       tf2 = new TextField("");
  22.       p.add(tf2);
  23.  
  24.       add("North", p);
  25.  
  26.       p = new Panel();
  27.  
  28.       p.setLayout(new GridLayout(1, 3));
  29.       p.add(new Label(""));
  30.       p.add(new Button("Copy"));
  31.       p.add(new Label("")); 
  32.       add("South", p);
  33.  
  34.    }
  35.  
  36.     public boolean action(Event evt, Object arg)     {
  37.        if (evt.target instanceof Button)        {
  38.          String s1 = tf1.getText();
  39.          tf2.setText(s1);
  40.          return true;
  41.      }  // end action()
  42.     return false;
  43.    }
  44.  
  45.    public static void main(String [] args)
  46.    {
  47.       Frame f = new Frame("copytext");
  48.  
  49.       copytext ex = new copytext();
  50.  
  51.       ex.init();
  52.  
  53.       f.add("Center", ex);
  54.  
  55.       f.pack();
  56.       f.show();
  57.    }
  58.  
  59. }
  60.